﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace PlantsVsZombies
{
    public class Peashooter : AttackPlant
    {
        //ContentManager _content;
        
        public override Plant Clone()
        {
            Peashooter plant = new Peashooter();
            plant.Cost= this.Cost;
            plant.RechargeTime = this.RechargeTime;
            plant.Blood = this.Blood;
            plant.Size = this.Size;
            plant.Velocity = this.Velocity;
            plant.NBullet = this.NBullet;
            plant.LoadBulletTime = this.LoadBulletTime;
            plant.Bullet = new Sprite[plant.NBullet];
            Sprite bullet = MyContent.LoadBullet();
            for (int i = 0; i < nBullet; i++)
            {
                plant.Bullet[i] = bullet;
                plant.Bullet[i].Visible = false;
            }

            plant.NSprites = this.NSprites;
            plant.Sprites = new List<Sprite>();
            for(int i=0; i<plant.NSprites; i++)
            {
                plant.Sprites.Add(this.Sprites[i]);
                plant.Sprites[i].State = -1;
            }
            return (Plant)plant;
            

        }
       
        public Peashooter(){}


        public Peashooter(ContentManager content,Vector2 size)
        {
            
            Cost = 100;
            RechargeTime = 2;
            Blood = 10f;
            nBullet = 1;
            Velocity = 2f;
            LoadBulletTime = 2.0f;
            Bullet = new Sprite[nBullet];
            this.PlantStatus = PlantStatus.Normal;

            for (int i = 0; i < nBullet; i++)
            {
                Bullet[i] = MyContent.LoadBullet();
                Bullet[i].Visible = false;
            }

            NSprites = 2;
            Sprite[] temp = new Sprite[NSprites];
            temp = MyContent.LoadPeashooter();
            Sprites = new List<Sprite>();

            if (Math.Abs(Size.X - 0) > 0.01f)
                Size = size;
            else
            {
                Size = temp[0].Size;
            }
            Sprites.Add(temp[0]);
            Sprites.Add(temp[1]);

        }
      
    }
}
